package com.lanhe.app.controller.article;


import com.lanhe.article.domain.LhArticle;
import com.lanhe.article.service.ILhArticleService;
import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文章表(LhArticle)表控制层
 *
 * @author zhanggl
 * @since 2023-12-18 09:23:41
 */
@RestController
@RequestMapping("/api/article")
public class ApiArticleController extends BaseController {

    /**
     * 服务对象
     */
    @Resource
    private ILhArticleService lhArticleService;

    /**
     * 分页查询所有数据
     */
    @GetMapping("/list")
    public TableDataInfo list(LhArticle article) {
        startPage();
        List<LhArticle> list = lhArticleService.selectArticleList(article);
        return getDataTable(list);
    }

    /**
     * 根据编号获取详细信息
     */
    @GetMapping(value = {"/", "/{articleId}"})
    public AjaxResult getInfo(@PathVariable(value = "articleId") Long articleId) {
        return success(lhArticleService.selectArticleById(articleId));
    }
}

